function f = markup_sim(theta2,v_c,delta_i,s_indiv,A1_i,s_mkt)

ns=length(v_c);
numobs=length(delta_i);

alpha=theta2(1,1);
sigmap=theta2(1,end);
ddelt=-alpha+sigmap*repmat(v_c(1,:),numobs,1); 

s11=s_indiv; 

s11star=s11.*ddelt;
A2=diag(-mean(s11star.*(1-s11),2))+(1-eye(size(s11,1),size(s11,1))).*(s11star*s11'./ns);

A=A1_i.*A2; 

f=A\s_mkt;

end